package cn.fl.system.service.impl;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSONObject;

import cmm.comm.facade.upload.api.IUploadApiService;
import cmm.comm.facade.upload.dto.SysUlDatCfgDtlDTO;
import cn.cmm.base.framework.constant.BaseExceptionConstant;
import cn.cmm.base.framework.exception.BaseException;
import cn.cmm.base.framework.utils.BaseLogUtils;
import cn.cmm.base.framework.utils.CollectionUtils;
import cn.cmm.base.framework.utils.StringUtils;
import cn.fl.framework.base.context.CurrentThreadContext;
import cn.fl.system.service.ISysUlDatCfgDtlService;
import cn.fl.system.transform.SysUlDatCfgDtlVOTransform;
import cn.fl.system.vo.SysUlDatCfgDtlVO;

/**
 * @Description: 上传资料配置明细表 客户端服务层接口实现
 * 业务层方法名称前缀：
 * 新增：add*
 * 删除：remove*
 * 修改：modify*
 * 批量：batch*
 * 查询对象：select* get*
 * 查询集合：search*
 */
@Service
public class SysUlDatCfgDtlServiceImpl implements ISysUlDatCfgDtlService {

	/**
	 * 日志
	 */
	private static final Logger logger = LoggerFactory.getLogger(SysUlDatCfgDtlServiceImpl.class);
	
	/**
	 * TODO 自定义 API 暴露服务
	 */
	@Autowired
	private IUploadApiService uploadApiService;

	@Override
	public SysUlDatCfgDtlVO selectById(Long id) throws BaseException{
		if(StringUtils.isEmpty(id))return null;
		//TODO 业务逻辑
		SysUlDatCfgDtlDTO dto = null;//this.自定义ApiService.selectById(id);
		return SysUlDatCfgDtlVOTransform.toVO(dto);
	}

	@Override
	public Long add(SysUlDatCfgDtlVO entity) throws BaseException{
		if(null == entity){
			BaseLogUtils.info(logger, "add", "新增上传资料配置明细失败,上传资料配置明细对象为空.DATA:"+JSONObject.toJSONString(entity), CurrentThreadContext.getCurrentUserName());
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600,BaseExceptionConstant.BASE_EXCEPTION_CODE_600_NAME);
		}
		return this.uploadApiService.addSysUlDatCfgDtl(SysUlDatCfgDtlVOTransform.toDTO(entity));
	}

	@Override
	public boolean removeByIds(List<Long> ids) throws BaseException {
		if(CollectionUtils.isEmpty(ids)){
			BaseLogUtils.info(logger, "removeByIds", "删除上传资料配置明细失败,主键参数为空.IDS:"+JSONObject.toJSONString(ids), CurrentThreadContext.getCurrentUserName());
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600,BaseExceptionConstant.BASE_EXCEPTION_CODE_600_NAME);
		};
		return this.uploadApiService.removeSysUlDatCfgDtlByIds(ids);
	}

	@Override
	public boolean modify(SysUlDatCfgDtlVO entity) throws BaseException{
		if(null == entity)return false;
		//return this.sysUlDatCfgDtlApiService.modify(SysUlDatCfgDtlVOTransform.toDTO(entity));
		//TODO 业务逻辑
		return false;
	}

}
